package org.jtb.quickr;

import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

class PeopleGetPublicGroupsRequest extends MethodRequest {
    private String nsid;
    
    protected PeopleGetPublicGroupsRequest(String baseUrl, String apiKey, String nsid) throws QuickrException {
        super(baseUrl, apiKey, "flickr.people.getPublicGroups");
        this.nsid = nsid;
    }
    
 
    protected Map<String,String> getArgs() {
        putArg("user_id", nsid);
        
        return super.getArgs();
    }
    
    public GroupsResponse execute() throws QuickrException {
        FlickrUrl furl = new ServiceMethodUrl(getBaseUrl(), getArgs(), getApiKey(), getMethod());
        
        Get get = new Get(furl.getUrl());
        InputStream is = get.execute();

        GroupsResponse gres = new GroupsResponse(is);
        
        return gres;
    }
}
